require "import"
import "str"

pcall(function () isFloatEnabled=io.open(启用浮窗):read("*a") end)
if isFloatEnabled=="true" then
  isFloatEnabled=true
 else
  isFloatEnabled=false
end

pcall(function () floatPreview=loadbitmap ("http://zt.agyer.xyz/app/xianyan/tp/FloatWindow.png") end)

this.setContentView(loadlayout ({
  RelativeLayout,
  layout_width="fill",
  layout_height="fill",
  --visibility=4,
  backgroundColor=背景色,
  --orientation="vertical",
  --elevation="2%w",
  paddingTop=状态栏高度,
  {
    ScrollView,
    layout_width="fill",
    {
      LinearLayout,
      layout_width="fill",
      orientation="vertical",
      {
        LinearLayout,
        paddingTop="56dp",
      },
      {
        TextView,
        text="以下为仍在开发或有已知问题的功能",
        textColor=淡色,
        textSize="12sp",
        layout_width="fill",
        gravity="center",
        --visibility=8,
        paddingBottom="8dp",
        paddingLeft="16dp",
        paddingRight="16dp",
      },
      {
        FrameLayout,
        layout_width="fill",
        onClick=function ()
          floats.performClick()
        end,
        foreground=波纹(波纹色),
        {
          TextView,
          text="句子浮窗",
          textColor=文字色,
          textSize="16sp",
          padding="16dp",
          gravity="center",
          layout_height="fill",
        },
        {
          Switch,
          padding="16dp",
          layout_gravity="right|center",
          onCheckedChangeListener={
            onCheckedChanged=function (v,c)
              io.open(启用浮窗,"w+"):write(tostring(c)):close()
              --toast("返回主页面生效，离开主页面后显示")
            end},
          id="floats",
          checked=isFloatEnabled,
        },
      },
      {
        TextView,
        padding="27dp",
        textSize="14sp",
        textColor=次要文字色,
        text=Html.fromHtml("\t\t开启/关闭后，<strong>回到主页面生效，离开主页面后显示</strong>。<br/>\t\t开启后，会创建一个悬浮窗口，拖动标题部分可移动，可显示在其他应用上。<br/>\t\t隐藏后，返回主页面后会重新创建。<br/><br/>\t\t<strong>注意：此功能需要启用悬浮窗权限才能正常使用。</strong>"),
        paddingTop="8dp",
        paddingBottom="16dp",
      },
      {
        ImageView,
        ImageBitmap=floatPreview,
        colorFilter=nightOverlayColor or 0,
        id="float_example",
        layout_width="fill",
        adjustViewBounds=true,
      },
      {
        TextView,
        text="更多功能开发中",
        textColor=淡色,
        textSize="14sp",
        layout_gravity="center",
        padding="32dp",
        backgroundColor=背景色,
        gravity="center",
      },
      --lab
    },
  },
  {
    LinearLayout,
    layout_width="fill",
    layout_height="44dp",
    foreground=上下渐变({背景色,深透,淡透}),
  },
  {
    RelativeLayout,
    layout_width="fill",
    layout_height="56dp",
    gravity="center",
    padding="16dp",
    paddingTop="8dp",
    paddingBottom="8dp",
    {
      ImageView,
      src="drawable/back.png",
      layout_height="fill",
      layout_width="44dp",
      foreground=波纹(波纹色),
      onClick=function ()
        this.finish()
      end,
      padding="9dp",
      colorFilter=图标色,
    },
    {
      TextView,
      layout_width="fill",
      layout_height="fill",
      gravity="center",
      --layout_gravity="center",
      text="探索功能",
      textSize="20sp",
      textColor=文字色,
    },
  },
}))